<?php


class category{

	private $db;

	private $childrenList;
	
	//nazwa kategorii
	private $name;
	

	function __construct($url){
		try {

			$this->db = pg_connect("host='".DB_HOST."' dbname='".DB_NAME."' user='".DB_USER."' password='".DB_PASS."'");
		}catch (Exception $e){
			echo $e->getMessage();
		}

		$this->setChildrens($url);

		return 0;
	}

	function setChildrens($url){
		try {
			$query = "Select name_pl,p.url,calories from products  p , categories c
							where p.id_categories = c.id
							AND c.url = '".$url."'";
			$result = pg_query($this->db,$query);
			$row = pg_fetch_all($result);

		}catch (Exception $e){
			echo $e->getMessage();
		}

		$this->childrenList=$row;
		//print_r($this->childrenList);
		return 0;
	}

	function getChildrenList(){
		return $this->childrenList;
	}

}

$x = new category('nabial');
?>